<%@page contentType="text/html" %>
<%@page pageEncoding="UTF-8" %>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
<%@taglib prefix="rich" uri="http://richfaces.org/rich" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Goodwill - Остатки на складе</title>
    <link rel="stylesheet" href="resources/css/main.css"/>
    <link rel="stylesheet" href="resources/css/stylesheet.css"/>
    <link rel="stylesheet" type="text/css" href="resources/css/jquery.countdown.css">
    <script type="text/javascript">
        function reloadPage() {
            window.location.reload();
        }
    </script>
    <style type="text/css">
        .rich-table-cell{
            font-size: 1.1em;
            text-align: center;
        }
    </style>
</head>
<body>
<f:view>
    <jsp:include page="StorageMenu.jsp"/>
    <h:form>
        <h:outputText value="Фильтр: " styleClass="b"/>
        <h:panelGroup layout="block" styleClass="filter_subpanel">
            <h:outputText value=" c "/>
            <rich:calendar value="#{ReceiptAndDebitingBean.filter.beginDate}" locale="RU_ru"
                           datePattern="dd.MM.yyyy" style="width:80px;padding-left:4px;" id="calBegdate" required="true" requiredMessage="Необходимо выбрать временной период"/>
            <h:outputText value=" по "/>
            <rich:calendar value="#{ReceiptAndDebitingBean.filter.endDate}" locale="RU_ru"
                           datePattern="dd.MM.yyyy" style="width:80px;padding-left:4px;" id="calEnddate" required="true" requiredMessage="Необходимо выбрать временной период"/>
        </h:panelGroup>

        <h:panelGroup layout="block" styleClass="filter_subpanel">
            <h:outputText value="Код"/>
            <h:inputText value="#{ReceiptAndDebitingBean.goodCode}" styleClass="f_tb_s"/>
        </h:panelGroup>

        <h:panelGroup layout="block" styleClass="filter_subpanel">
            <h:outputText value="Группа товара"/>
            <h:selectOneMenu value="#{ReceiptAndDebitingBean.filter.goodTypeId}" styleClass="f_s">
                <f:selectItems value="#{StorageEnteranceBean.goodTypesAsSelectItems}"/>
            </h:selectOneMenu>
        </h:panelGroup>

        <h:panelGroup layout="block" styleClass="filter_subpanel">
            <h:outputText value="Тип операции"/>
            <h:selectOneMenu value="#{ReceiptAndDebitingBean.filter.operationType}">
                <f:selectItems value="#{ReceiptAndDebitingBean.operationTypes}"/>
            </h:selectOneMenu>
        </h:panelGroup>

        <a4j:commandButton value="Применить" action="#{ReceiptAndDebitingBean.applyFilter}" reRender="tb1"/>

        <div align="center">

        </div>
        <rich:dataTable id="tb1" value="#{ReceiptAndDebitingBean.receiptAndDebitingModels}"
                        var="model"
                        rowKeyVar="row"
                        rows="20"
                        style="width: 60%; text-align: center;">

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="№"/>
                </f:facet>
                <h:outputText value="#{row + 1}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Код товара"/>
                </f:facet>
                <h:outputText value="#{model.goodCode}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Тип операции"/>
                </f:facet>
                <h:outputText value="#{model.operationType}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Количество"/>
                </f:facet>
                <h:outputText value="#{model.goodCount}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Дата/время"/>
                </f:facet>
                <h:outputText value="#{model.dateAsString}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Пользователь"/>
                </f:facet>
                <h:outputText value="#{model.userName}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Примечание"/>
                </f:facet>
                <h:outputText value="#{model.comment}"/>
            </rich:column>

            <f:facet name="footer">
                <rich:datascroller id="datascroller"/>
            </f:facet>
        </rich:dataTable>
    </h:form>
</f:view>
</body>
</html>
